#include "oj_common/oj_log.h"
namespace ojlb {
namespace oj_common {

// TODO: Cpp 的模板函数实现必须放在头文件中...

void OjLog::setShieldLevel(const std::string &level) {
    if (level == "trace") {
        logger->set_level(spdlog::level::trace);
    } else if (level == "debug") {
        logger->set_level(spdlog::level::debug);
    } else if (level == "info") {
        logger->set_level(spdlog::level::info);
    } else if (level == "warn") {
        logger->set_level(spdlog::level::warn);
    } else if (level == "error") {
        logger->set_level(spdlog::level::err);
    } else if (level == "off") {
        logger->set_level(spdlog::level::off);
    } else {
        exit(-1); // TODO: 抛出异常
    }
}

std::shared_ptr<spdlog::logger> OjLog::logger = OjLog::initializeLogger();

std::shared_ptr<spdlog::logger> OjLog::initializeLogger() {
    // TODO: 修改为文件日志
    auto logger = spdlog::stdout_color_mt("console"); // 注意这个日志对象本身就是一个智能指针对象
    return logger;
}


} // namespace oj_common end
} // namespace ojlb end